<?php
/**
 * Created by PhpStorm.
 * User: kkw
 * Date: 2019/5/23
 * Time: 19:21
 */
namespace kkw\user\response;
use kkw\user\Util;
use kkw\user\table\UserTable;
use suda\core\Request;
use suda\core\Response;

class EarnOneUserResponse extends  Response
{
    public function onRequest(Request $request)
    {
        // 引用头文件
        Util::printHeader();
        // 实例化用户表
//      前端数据
//        $json = Request::json();
//        $id= $json['id'];
        // 根据id查询一条数据
        try {
            $user = new UserTable();
//            $userData = $user->select('*',['id'=> $id])->fetch();
            $userData = $user->list();
        } catch (\suda\exception\SQLException $e) {
            $this->json(['code'=> $e->getCode(), ',message'=>'查询数据失败']);
        }
        $this->json([
            'code'=> 0,
            'data'=>$userData
        ]);
    }
}